fix(route/reuters): Adjust header#22086
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates Reuters route fetching to use the shared header generator presets (Modern Windows) instead of manually passing a static browser-like header set.
Changes:
- Import
PRESETSfrom the header generator utility. - Switch
ofetchcalls fromheaders: browserHeaderstoheaderGeneratorOptions: PRESETS.MODERN_WINDOWS. - Add a hardcoded
User-Agentto the localbrowserHeadersobject.
Comments suppressed due to low confidence (2)
lib/routes/reuters/common.tsx:1
- Switching from
headers: browserHeadersto onlyheaderGeneratorOptionsrisks dropping required request headers (e.g.,Accept,Accept-Language,Referer) that Reuters may rely on for correct responses. Ifofetchsupports both, passheadersalongsideheaderGeneratorOptions, or generate headers and merge in the required overrides (especiallyAcceptandReferer) before making the request.
import { load } from 'cheerio';
lib/routes/reuters/common.tsx:1
- Same issue as the content request: this section request previously sent explicit
browserHeaders, but now relies solely on the header generator preset. To avoid regressions (unexpected content negotiation, geo/language differences, or blocked responses), ensure the critical headers previously set are still applied (e.g., by mergingbrowserHeadersas overrides on top of generated headers).
import { load } from 'cheerio';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
Auto ReviewNo clear rule violations found in the current diff. |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
| rootUrl, | ||
| response, | ||
| }; | ||
| } else { |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
Auto ReviewNo clear rule violations found in the current diff. |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
| size: limit, | ||
| section_id, | ||
| website: 'reuters', | ||
| ...(useSophi |
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
Involved Issue / 该 PR 相关 Issue
Close #
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明